export default { 
	data(){
		return {
			//测试
			serverUrl:'http://127.0.0.13/employee/',
			cdnUrl:'https://cdn.xjyuanda.com/',
			miniMode:2,
			//正式
			// serverUrl:'https://server.xjyuanda.com/employee/',
			// cdnUrl:'https://cdn.xjyuanda.com/',
			// miniMode:2,
			// socketUrl:'ws://im.mingtangji.com:8181',
			// imUrl:'http://im.mingtangji.com/',
			// gyUserUrl:'http://gyuser.mingtangji.com/',
			// javaUrl:'http://java.mingtangji.com/',
			// skey:'wD23SFe4gdf1r',
			// miniAppId:'gh_514573ba42a4',
			// redMiniAppId:'gh_48e0f55a005e',
			// homeUrl:'http://mall.mingtangji.com/',
			// miniMode:0,
		}
	},
    
	methods:{
		shareWeibo(path,imageUrl,title){
			
			uni.share({
				provider: 'sinaweibo',
				type:0,
				// imageUrl: imageUrl,
				title: title,
				href:path,
				summary:title,
				success: ret => {
					console.log(JSON.stringify(ret));
				},fail: function (err) {
							console.log("fail:" + JSON.stringify(err));
						}
			})
		},
		shareQQ(path,imageUrl,title){
			
			uni.share({
				provider: 'qq',
				type:0,
				imageUrl: imageUrl,
				title: title,
				href:path,
				success: ret => {
					console.log(JSON.stringify(ret));
				},fail: function (err) {
							console.log("fail:" + JSON.stringify(err));
						}
			})
		},
		shareRedBag(path,scene,imageUrl,title,type=0){
			//var path="pages/index/index?store_id="+this.storeId+'&fuid='+this.fuid;
			uni.share({
				provider: 'weixin',
				scene: scene,
				type: 5,
				imageUrl: imageUrl,
				title: title,
				miniProgram: {
					id: this.redMiniAppId,
					path: path,
					type: type,
					webUrl: 'http://guanyumall.com'
				},
				success: ret => {
					console.log(JSON.stringify(ret));
				},fail:e=>{
					console.log(e);
				}
			})
		},
		shareWechat(path,scene,imageUrl,title,type=0){
			//var path="pages/index/index?store_id="+this.storeId+'&fuid='+this.fuid;
			uni.share({
				provider: 'weixin',
				scene: scene,
				type: 5,
				imageUrl: imageUrl,
				title: title,
				miniProgram: {
					id: this.miniAppId,
					path: path,
					type: type,
					webUrl: 'http://guanyumall.com'
				},
				success: ret => {
					console.log(JSON.stringify(ret));
				},fail:e=>{
					console.log(e);
				}
			})
		},
		fuzhi(data){
			uni.setClipboardData({
			data: data,
			success: function() {
			//调用方法成功
			console.log('success');
			}
			})
		},
		call(phone){
			uni.makePhoneCall({
				phoneNumber:phone
			})
		},
		jsDateToDate(jsDate){
			var date = jsDate; // 时间戳转换为Date对象
			var year = date.getFullYear(); // 获取年份
			var month = date.getMonth() + 1; // 获取月份，月份需要+1
			var day = date.getDate(); // 获取日
			var hours = date.getHours(); // 获取小时
			var minutes = date.getMinutes(); // 获取分钟
			var seconds = date.getSeconds(); // 获取秒钟
					 
			// 格式化月份、日期、小时、分钟、秒
			month = month < 10 ? '0' + month : month;
			day = day < 10 ? '0' + day : day;
			hours = hours < 10 ? '0' + hours : hours;
			minutes = minutes < 10 ? '0' + minutes : minutes;
			seconds = seconds < 10 ? '0' + seconds : seconds;
					 
			// 组合成 yyyy-MM-dd HH:mm:ss 格式
			return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
		},
		timestampToDate(timestamp) {
		    var date = new Date(timestamp); // 时间戳转换为Date对象
		    var year = date.getFullYear(); // 获取年份
		    var month = date.getMonth() + 1; // 获取月份，月份需要+1
		    var day = date.getDate(); // 获取日
		    var hours = date.getHours(); // 获取小时
		    var minutes = date.getMinutes(); // 获取分钟
		    var seconds = date.getSeconds(); // 获取秒钟
		 
		    // 格式化月份、日期、小时、分钟、秒
		    month = month < 10 ? '0' + month : month;
		    day = day < 10 ? '0' + day : day;
		    hours = hours < 10 ? '0' + hours : hours;
		    minutes = minutes < 10 ? '0' + minutes : minutes;
		    seconds = seconds < 10 ? '0' + seconds : seconds;
		 
		    // 组合成 yyyy-MM-dd HH:mm:ss 格式
		    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
		},
		formatMoney(money){
			let moneyObj={z:'0',x:'00',f:'0.00'}
			let moneyStr=parseFloat(money).toFixed(2).toString();
			moneyObj.z=moneyStr.split('.')[0];
			moneyObj.x=moneyStr.split('.')[1];
			moneyObj.f=moneyStr;
			moneyObj.fh=moneyStr.charAt(0)=='-'?false:true;
			
			return moneyObj;
		},
		toNav(url){
			uni.navigateTo({
				url:url
			})
		},
		toBack(){
			uni.navigateBack();
		},
		needLoginToNav(url){
			if(uni.getStorageSync('token')){
				uni.navigateTo({
					url:url
				})
			}else{
				
				uni.navigateTo({
					url:"/pages/login/login"
				})
				
			}
		},
		toTab(url){
			uni.switchTab({
				url:url
			})
		},
		//拉起支付宝支付
		doAliPay(info) {
		
			
			uni.requestPayment({
				provider: 'alipay',
				orderInfo: info.pay,
				success: function(res) {
					uni.redirectTo({
						url:'/pages/my/order/paySuccess?id='+info.order_id
					})
				},
				fail: function(err) {
					uni.redirectTo({
						url:'/pages/my/order/detail?id='+info.order_id
					})
				}
			})
			
		},
		//拉起分期支付
		doAliPayFenqi(info) {
			
			uni.requestPayment({
				provider: 'alipay',
				orderInfo: info.pay,
				success: function(res) {
					uni.redirectTo({
						url:'/pages/my/order/paySuccess?id='+info.order_id
					})
				},
				fail: function(err) {
					uni.redirectTo({
						url:'/pages/my/order/detail?id='+info.order_id
					})
				}
			})
		},
		//拉起微信支付
		doWechatPay(info) {
			uni.requestPayment({
				provider: 'wxpay',
				orderInfo: info.pay,
				success: function(res) {
					uni.redirectTo({
						url:'/pages/my/order/paySuccess?id='+info.order_id
					})
				},
				fail: function(err) {
					uni.redirectTo({
						url:'/pages/my/order/detail?id='+info.order_id
					})
				}
			})
		},
	}
}
